﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnvDTE;
using EnvDTE80;

namespace BovespaMaintainabilityRules
{
    public sealed class Rule_ClassFieldsMustHaveInLineComments : BaseAddIn.Rules.BaseRuleAddIn
    {
        public Rule_ClassFieldsMustHaveInLineComments()
            : base("BovespaClassFieldsMustHaveInLineComments",
                   "BovespaMaintainabilityRules.BovespaMaintainabilityRules",
                   typeof(Rule_ClassFieldsMustHaveInLineComments).Assembly)
        {
        }

        protected sealed override void Check(CodeFunction funcao, CodeNamespace namespaceElement, CodeClass2 classe)
        {
            if (funcao.FunctionKind == vsCMFunction.vsCMFunctionFunction
                && (String.IsNullOrEmpty(funcao.DocComment)
                    || funcao.DocComment == "<doc>\r\n</doc>"))
            {                
                GeraProblemaAddIn(funcao.StartPoint.Parent.Parent.FullName,
                                    funcao.StartPoint.Line,
                                    funcao.StartPoint.DisplayColumn,
                                    "ClassMethodsMustHaveInLineCommentsResolution",
                                    classe.Name,
                                    funcao.Name,
                                    namespaceElement.Name);
            }
        }

        protected sealed override void Check(CodeProperty propriedade, CodeNamespace namespaceElement, CodeClass2 classe)
        {
            if (String.IsNullOrEmpty(propriedade.DocComment)
                    || propriedade.DocComment == "<doc>\r\n</doc>")
            {
                GeraProblemaAddIn(propriedade.StartPoint.Parent.Parent.FullName,
                                   propriedade.StartPoint.Line,
                                   propriedade.StartPoint.DisplayColumn,
                                   "ClassFieldsMustHaveInLineCommentsResolution",
                                   classe.Name,
                                   propriedade.Name,
                                   namespaceElement.Name);
            }
        }
    }
}
